/*
 * @Author: TC
 * @Date: 2025-06-20 14:20:49
 * @Last Modified by: TC
 * @Last Modified time: 2025-06-20 14:28:47
 */
import { _decorator, Component, Node } from "cc";
import { BaseComponent } from "db://assets/FrameWork/Module/Component/BaseComponent";
import { gameDataMgr } from "db://assets/Script/_Common/Manager/GameDataManager";
const { ccclass, property } = _decorator;

/**
 * 技能按钮
 */
@ccclass("BtnSkill")
export class BtnSkill extends BaseComponent {
    @property({ displayName: "插槽索引" })
    slotIndex: number = 0;

    protected addUIEvent(): void {
        super.addUIEvent();
        this.node.on(Node.EventType.TOUCH_START, this._onSkill, this);
    }

    /**
     * 点击技能
     */
    private _onSkill(): void {
        const hero = gameDataMgr.entityHero;
        if (hero) {
            hero.skill.useSkill(this.slotIndex);
        }
    }
}
